package com.ymnet.myretrofit;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
 * Created by life on 2017/2/26.
 */

public class NetUtil {

    public static boolean isNetworkAvailable(Context context) {
        //获得网络管理器
        ConnectivityManager connM =
                (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

        NetworkInfo netInfo = connM.getActiveNetworkInfo();//得到网络详情

        return netInfo != null && netInfo.isAvailable();
    }
}
